/'
    0MQ for FreeBASIC is a software library that lets you quickly design and
    implement a fast message-based application.

    http://www.zeromq.org
    http://mud.owlbox.net/projects/zeromq-freebasic

    Based on version 2.1.7 of 0MQ 

    Copyright (c) 2010-2011 Ebben Feagan <sir@mud.owlbox.net>
    
    This file is not part of 0MQ.

    0MQ for FreeBASIC is free software; you can redistribute it and/or modify it under
    the terms of the Lesser GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ for FreeBASIC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Lesser GNU General Public License for more details.

    You should have received a copy of the Lesser GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'/

#ifndef __ZEROMQ_4_FB_BI__
#define __ZEROMQ_4_FB_BI__ -1

#inclib "zmq"
#inclib "zmq4fb"

type zmq_msg_t_ref as zmq_msg_t

#ifndef null
#define null cast(any ptr, 0)
#endif

namespace zmq

        enum SocketType explicit
        PAIR = 0
        PUB = 1
        SUB_ = 2
        REQ = 3
        REP = 4
        DEALER = 5
        ROUTER = 6
        PULL = 7
        PUSH = 8
        XPUB = 9
        XSUB = 10
        end enum

        type Context
                public:
                declare constructor()
                declare constructor( byval rhs as const Context )
                declare destructor()

                declare function newMessage() as Message ptr
                declare function newSocket( byval t as SocketType ) as Socket ptr

                private:
                as any ptr m_context

        end type

        type freefunction as sub ( byval as any ptr )

        type Message
                public:
                declare constructor( byval cont as Context ptr )
                declare destructor()

                declare function copyTo( byval rhs as Message ptr ) as integer
                declare function moveTo( byval rhs as Message ptr ) as integer

                declare function store( byval dta as any ptr, byval data_len as uinteger, _
                                        byval fref as freefunction ptr ) as integer
                                        
                declare function retrieve( byval dta as any ptr ) as uinteger
                declare function size() as uinteger

                private:
                as zmq_msg_t_ref ptr m_msg
        end type

        enum SocketFlag
        noblock = 1
        sendmore = 2
        end enum

        enum SocketOption explicit
        HWM = 1
        zSWAP = 3
        AFFINITY = 4
        IDENTITY = 5
        SUBSCRIBE = 6
        UNSUBSCRIBE = 7
        RATE = 8
        RECOVERY_IVL = 9
        MCAST_LOOP = 10
        SNDBUF = 11
        RCVBUF = 12
        RCVMORE = 13
        FD = 14
        EVENTS = 15
        zTYPE = 16
        LINGER = 17
        RECONNECT_IVL = 18
        BACKLOG = 19
        RECOVERY_IVL_MSEC = 20   '/*  opt. recovery time, reconcile in 3.x   */
        RECONNECT_IVL_MAX = 21
        end enum



        type Socket
                public:
                declare constructor()
                declare destructor()

                declare function bind( byref address as const string ) as integer
                declare function connect( byref address as const string ) as integer

                declare function send( byval msg as Message ptr, flags as SocketFlag ) as integer
                declare function recv( byval msg as Message ptr, flags as SocketFlag ) as integer

                declare function setOption( byval socko as SocketOption, byval oval as any ptr, byval size_oval as uinteger ) as integer
                declare function getOption( byval socko as SocketOption, byval oval as any ptr, byval size_oval as uinteger ) as integer

                private:
                as any ptr m_socket

        end type

end namespace

#endif '__ZEROMQ_4_FB_BI__